/* (C) 2007-2009 caitong Limited
 * (C) 2009-2012  limited
 *
 * Authors:
 * legs.ant.king@gmail.com


   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
#include "../include/iGetCfg.h"
#include "../include/InitVariable.h"
#include <string>
#include <string.h>
#include <iostream>
#include "../include/help.h"
using namespace std;

void GetCfg(int argc,char **argv,char iArgument[][50],char iCompasion[][50])
{
	char *defaultcfg="/etc/repmsg.cnf";
	int jbx=GetMatachChar(iCompasion,"Config");
	int iargc=0;
	int iargci=0;
	while(iargc<argc)
	{
		
		if(strcmp(argv[iargc],"-h")==0 || strcmp(argv[iargc],"--help")==0)
		{
			usage(argv);
		}
		if(strcmp(argv[iargc],"-c")==0 || strcmp(argv[iargc],"--config")==0)
		{
			cout<<iargc<<endl;
			iargci=++iargc;
			break;
		}
		iargc++;
	}
	if(iargci==0)
	{
		cout<<"Not Found Config file , feture use default config file"<<defaultcfg<<endl;
		strcpy(iArgument[jbx],defaultcfg);
	}
	else
	{
		if(iargci>=argc)
		{
			cout<<"Argument Error use default config file"<<defaultcfg<<endl;
			strcpy(iArgument[jbx],defaultcfg);
		}
		else
		{
		cout<<"use specify config file"<<argv[iargci]<<endl;
		strcpy(iArgument[jbx],argv[iargci]);
		}
		
		
	}
}

